package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.Booking;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CompanyMapper;
import com.ruoyi.system.domain.Company;
import com.ruoyi.system.service.ICompanyService;

import javax.annotation.Resource;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-03
 */
@Service
public class CompanyServiceImpl implements ICompanyService 
{
    @Autowired
    private CompanyMapper companyMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param companyId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public Company selectCompanyByCompanyId(Long companyId)
    {
        Company company = companyMapper.selectCompanyByCompanyId(companyId);
        company.setTerm(company.getTerm().substring(0,companyMapper.selectCompanyByCompanyId(companyId).getTerm().length()-1));
        return company;
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param company 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<Company> selectCompanyList(Company company)
    {

        return companyMapper.selectCompanyList(company);
    }
    public List<Company> CompanyList(){
        return companyMapper.CompanyList();
    }
    /**
     * 新增【请填写功能名称】
     * 
     * @param company 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertCompany(Company company)
    {
        company.setAddTime(DateUtils.getNowDate());
        company.setFakeDelete(1L);
        company.setTerm(company.getTerm()+"年");
        return companyMapper.insertCompany(company);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param company 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateCompany(Company company)
    {
        company.setUpdateTime(DateUtils.getNowDate());
        company.setTerm(company.getTerm()+"年");
        return companyMapper.updateCompany(company);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param companyIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCompanyByCompanyIds(Long[] companyIds)
    {
        return companyMapper.deleteCompanyByCompanyIds(companyIds);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param companyId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCompanyByCompanyId(Long companyId)
    {
        return companyMapper.deleteCompanyByCompanyId(companyId);
    }
}
